# coding:utf-8
# 作者：理想国真恵玩
# 导入依赖
import pandas as pd

# 准备数据
df_stock = pd.read_csv('data/stock.csv')
df_stock_p_change = df_stock['p_change']

# 数据离散化(pd.cut())
bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]
df_stock_p_change_cut = pd.cut(df_stock_p_change, bins)
print(df_stock_p_change_cut.value_counts())
print('-' * 33)

# one-hot编码(pd.get_dummies())
# df_stock_p_change_one_hot = pd.get_dummies(df_stock_p_change_cut, prefix='p_change')
df_stock_p_change_one_hot = pd.get_dummies(df_stock_p_change_cut)

# 查看效果
print(df_stock_p_change_one_hot)
